

#ifndef _UART_COMM_STRUCT_H_
#define _UART_COMM_STRUCT_H_

#include "stdint.h"

#define FRAME_HEAD_H  0xF0
#define FRAME_HEAD_L  0xF0

#define LEGTH_CMD_ID       2

// Navigation send mesg frame to MCU --------

#define ID_CMD_HEARTBEAT       0x0101
#define ID_CMD_TIME_SET        0x0107
#define ID_CMD_P_OFF_TYPE      0x0418
#define ID_CMD_BREAK_SHIELD    0x0421
#define ID_CMD_LED_BUZZER      0x0420
#define ID_CMD_SET_RTC_TIME    0x0422

#define ID_CMD_CLEAN_CTRL      0x04F0

#define DATA_LEGTH_HEARTBEAT     2
#define DATA_LEGTH_TIME_SET      8
#define DATA_LEGTH_P_OFF_TYPE    1
#define DATA_LEGTH_BREAK_SHIELD  4
#define DATA_LEGTH_LED_BUZZER    6
#define DATA_LEGTH_SET_RTC       8

#define DATA_LEGTH_CLEAN_CTRL    12 

// MCU send mesg frame to Navigation --------

#define ID_ULTRASOUND_UPLOAD   0x0415
#define ID_CHARGE_POS_UPLOAD   0x0417

#define ID_BUMPER_UPLOAD       0x0206
#define ID_CLIFF_UPLOAD        0x0205
#define ID_IO_SIGNAL_UPLOAD    0x020F

#define ID_P_OFF_REQ_UPLOAD    0x0419
#define ID_CHARGE_FSM_UPLOAD   0x020A

#define ID_RCT_TIME_UPLOAD     0x020B
#define ID_VOT_CUR_UPLPAD      0x020C

#define ID_CLE_STATUS_UPLOAD   0x020D
#define ID_CLE_SENSOR_UPLOAD   0x020E


#define DATA_LEGTH_CHARGE_POS  6
#define DATA_LEGTH_BUMPER      4
#define DATA_LEGTH_CLIFF       8
#define DATA_LEGTH_ULTRASOUMD  6
#define DATA_LEGTH_IO_SIGNAL   8
#define DATA_LEGTH_P_OFF_REQ   4

#define DATA_LEGTH_CHARGE_FSM  4
#define DATA_LEGTH_RTC_TIME    8

#define DATA_LEGTH_VOT_CUR     12

#define DATA_LEGTH_CLE_STATUS  10
#define DATA_LEGTH_CLE_SENSOR  10


// -----------------------------------------

typedef union
{
	struct
	{
		uint64_t time;
	}real;
	
	uint8_t data[8];

}STR_COMM_TIME_SET;


typedef union
{
	struct
	{
		uint16_t heartbeat;
	}real;
	
	uint8_t data[2];


}STR_COMM_HEARTBEAT;


typedef union
{
	struct
	{
		uint8_t type;
	}real;
	
	uint8_t data;

}STR_COMM_P_OFF_TYPE;



typedef union
{
	struct
	{
		uint8_t bumper;
		uint8_t cliff;
		uint8_t break_soft;
		uint8_t reserve;
		
	}real;
	
	uint8_t data[4];


}STR_COMM_SHIELD;



typedef union
{
	struct
	{
		uint8_t turn_left;
		uint8_t turn_right;
		uint8_t LED_left;
		uint8_t LED_right;
		uint8_t buzzerX1;
		uint8_t buzzerX2;
	
	}real;
	
	uint8_t data[6];


}STR_COMM_LED_BUZZER;




typedef union
{

	struct
	{
		uint8_t en_brush;
		uint8_t en_dustfan;
		uint8_t en_pump_water;
		uint8_t en_pump_agent;
		uint8_t level_press;
		uint8_t level_water;
		uint8_t dir_pump_waste;
		uint8_t pwm_pump_waste;
		uint8_t en_water_lift;
		uint8_t reserve;
		
	}real;
	
	uint8_t data[10];

}STR_COMM_CLE_CTRL;



typedef union
{
	struct
	{
		uint16_t time;
		uint8_t  chargeSignal[4];
	
	}real;

	uint8_t data[6];

}STR_UPLOAD_CHARGE;



typedef union
{
	struct
	{
		uint16_t time;
		uint8_t  bumper[2];
		uint8_t  break_key;
		uint8_t  break_sort;
		uint8_t  key_power;
		uint8_t  key_start;
	
	}real;

	uint8_t data[8];

}STR_UPLOAD_IO_SIGNAL;



typedef union
{
	struct
	{
		uint16_t time;
		uint8_t  cliff[6];
	
	}real;

	uint8_t data[8];

}STR_UPLOAD_CLIFF;



typedef union
{
	struct
	{
		uint16_t time;
		uint16_t ID;
		uint16_t distance_mm;
	}real;
	
	uint8_t data[6];
	
}STR_UPLOAD_ULTRASOUND;



typedef union
{
	struct
	{
		uint16_t time;
		uint16_t cnt_down_ms;
	
	}real;
	
	uint8_t data[4];

}STR_UPLOAD_P_OFF_REQ;

typedef union
{
	struct
	{
		uint16_t time;
		uint8_t  charge_FSM;
		uint8_t  battery_level;
		
	}real;
	
	uint8_t data[4];

}STR_UOLOAD_CHARGE_FSM;



typedef union
{
	struct
	{
		
        uint8_t second;
        uint8_t minute;
        uint8_t hour;
        uint8_t week;
        uint8_t day;
        uint8_t month;
        uint8_t year;
        uint8_t reserve;
		
	}real;
	
	uint8_t data[8];
		
	
}STR_UOLOAD_RTC_TIME;


typedef union
{
	struct
	{
		uint16_t vdc;
		uint16_t idc;
		uint16_t vdc_realy;
		uint16_t idc_motor;
		uint16_t idc_ctrl;
		uint16_t idc_service;
	
	}real;
	
	uint8_t data[12];

}STR_UOLOAD_VOT_CUR;



typedef union
{
	struct
	{
		uint8_t brush_FSM;
		uint8_t dustfan_FSM;
		uint8_t brush_lift_FSM;
		uint8_t water_lift_FSM;
		uint8_t brush_right_FSM;
	
	}real;
	
	uint8_t data[8];

}STR_UPLOAD_CLE_STATUS;


typedef union
{
	struct
	{
		uint8_t water_full;
		uint8_t water_level;
		uint8_t agent_level;
		uint8_t sink_full;
		uint8_t waste_full;
		uint8_t waste_empty;
		uint8_t reserve1;
		uint8_t reserve2;
	
	}real;
	
	uint8_t data[8];

}STR_UPLOAD_CLE_SENSOR;



#endif




